package com.aglhz.nature.view;



import com.aglhz.nature.R;
import com.aglhz.nature.presenter.BrandIntroductionPresenter;
import com.aglhz.nature.view.iv.BrandView;
import com.squareup.picasso.Picasso;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

public class BrandIntroductionActivity extends Activity implements BrandView{
	private ImageView iv_brand;
	private Button bt_showmore;
	private String BrandId;
	private WebView brandWebView;
	private TextView brandTitle;
	private ImageButton back;
	private BrandIntroductionPresenter presenter;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.brandintroduction);
		
		Intent intent =getIntent();
		BrandId = intent.getStringExtra("home_scroll");
		
		brandWebView=(WebView) findViewById(R.id.brandWebView);
		bt_showmore=(Button) findViewById(R.id.bt_showmore);
		brandTitle=(TextView) findViewById(R.id.brandTitle);
		back=(ImageButton) findViewById(R.id.back);
		back.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
			finish();
				
			
			}
		});
		bt_showmore.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
			Intent intent =new Intent(BrandIntroductionActivity.this,ShopListActivity.class);
			intent.putExtra("BrandIntroductionActivity", presenter.showMoreUrl());
			Log.e("BrandIntroductionActivity",  presenter.showMoreUrl());
			startActivity(intent);
				
			}
		});
		
		presenter = new BrandIntroductionPresenter(this);
		// basePresenter register
				presenter.register();
				presenter.loadImageView();
				
				
			
	}
	
	
	@Override
	public void onDestroy() {
		super.onDestroy();
		// basePresenter unregister
		presenter.unregister();
	}
	
	
	@Override
	public String setBrandId() {
	
		return BrandId;
	}


	@Override
	public void showWebViewImage(String url) {
		WebSettings webSettings = brandWebView.getSettings();  
        //设置WebView属性，能够执行Javascript脚本    
        webSettings.setJavaScriptEnabled(true);    
        //设置可以访问文件  
        webSettings.setAllowFileAccess(true);  
      //webview自适应屏幕
        webSettings.setUseWideViewPort(true); 
        webSettings.setLoadWithOverviewMode(true); 

        brandWebView.loadUrl(url);    
        //设置Web视图  
       
        brandWebView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
           
            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
            	
            	super.onPageStarted(view, url, favicon);
         
            
        	
            }
            
            @Override
    		public void onPageFinished(WebView view, String url) {
    			
    			super.onPageFinished(view, url);
    			

    		}
        });
     
		
	}


	@Override
	public void setTitle(String name) {
		brandTitle.setText(name);
	}





}
